const assert = require('assert');

const calc = require('../lib/async_calculate');

describe('#async_calculate.js', () => {
    // beforeEach(function(){
    //     console.log('\n');
    // });
    it('#async with done', (done) => {
        (async function(){
            try {
                let r = await calc();
                assert.strictEqual(r, 15);
                done();
            } catch (err) {
                done(err);
            }
        })();
    });

    // 上的try-catch写法比较的繁琐, 还有更简单的写法, 如下:

    it('#async function', async () => {
        let r = await calc();
        assert.strictEqual(r, 15);
    });
});
